<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>后台管理中心</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" />
    <link rel="stylesheet" href="/static/css/global.css" />
    <script type="text/javascript" src="/static/layui/layui.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header">
        <div class="layui-main">
            <a class="logo" href="/admin/index" target="_blank">
                <img src="/static/image/logo-top.png" alt="cadmin">
            </a>
            <ul class="layui-nav top-nav-container">
                <li class="layui-nav-item layui-this">
                    <a href="javascript:void(0)">首页</a>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:void(0)">系统设置</a>
                </li>
            </ul>
            <div class="top_admin_user">
                <a href="/" target="_blank">网站首页</a> |<a class="update_cache" href="javascript:void(0)">更新缓存</a> | <a class="logout_btn" href="javascript:void(0)">退出</a>
            </div>
        </div>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree left_menu_ul">
                <li class="layui-nav-item layui-nav-title">
                    <a>首页</a>
                </li>
                <li class="layui-nav-item first-item layui-this">
                    <a href="/admin/home" target="main">
                        <i class="layui-icon">&#xe638;</i>
                        <cite>首页面板</cite>
                    </a>
                </li>
            </ul>
            <ul class="layui-nav layui-nav-tree left_menu_ul setting_ul hide">
                <li class="layui-nav-item layui-nav-title">
                    <a>系统设置</a>
                </li>
                <li class="layui-nav-item first-item ">
                    <a href="/admin/setting/website" target="main">
                        <i class="layui-icon">&#xe620;</i>
                        <cite>站点设置</cite>
                    </a>
                </li>
                <li class="layui-nav-item">
                    <a href="/admin/setting/seo" target="main">
                        <i class="layui-icon"></i>
                        <cite>SEO设置</cite>
                    </a>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body iframe-container">
        <div class="iframe-mask" id="iframe-mask"></div>
        <iframe class="admin-iframe" id="admin-iframe" name="main" src="/admin/home"></iframe>
    </div>

    <div class="layui-footer footer">
        <div class="layui-main">
            <p>2016 © <a href="/">Lz_CMS</a></p>
        </div>
    </div>
</div>


<script type="text/javascript">
    layui.use(['layer', 'element','jquery','tree'], function(){
        var layer = layui.layer
            ,element = layui.element() //导航的hover效果、二级菜单等功能，需要依赖element模块
            ,jq = layui.jquery

        //头部菜单切换
        jq('.top-nav-container .layui-nav-item').click(function(){
            var menu_index = jq(this).index('.top-nav-container .layui-nav-item');
            jq('.top-nav-container .layui-nav-item').removeClass('layui-this');
            jq(this).addClass('layui-this');
            jq('.left_menu_ul').addClass('hide');
            jq('.left_menu_ul:eq('+menu_index+')').removeClass('hide');
            jq('.left_menu_ul .layui-nav-item').removeClass('layui-this');
            jq('.left_menu_ul:eq('+menu_index+')').find('.first-item').addClass('layui-this');
            var url = jq('.left_menu_ul:eq('+menu_index+')').find('.first-item a').attr('href');
            jq('.admin-iframe').attr('src',url);
            //出现遮罩层
            jq("#iframe-mask").show();
            //遮罩层消失
            jq("#admin-iframe").load(function(){
                jq("#iframe-mask").fadeOut(100);
            });
        });
        //左边菜单点击
        jq('.left_menu_ul .layui-nav-item').click(function(){
            jq('.left_menu_ul .layui-nav-item').removeClass('layui-this');
            jq(this).addClass('layui-this');
            //出现遮罩层
            jq("#iframe-mask").show();
            //遮罩层消失
            jq("#admin-iframe").load(function(){
                jq("#iframe-mask").fadeOut(100);
            });
        });

        //更新缓存
        jq('.update_cache').click(function(){
            loading = layer.load(2, {
                shade: [0.2,'#000'] //0.2透明度的白色背景
            });
            jq.getJSON('',function(data){
                if(data.code == 200){
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                        location.reload();//do something
                    });
                }else{
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                }
            });
        });

        //退出登陆
        jq('.logout_btn').click(function(){
            loading = layer.load(2, {
                shade: [0.2,'#000'] //0.2透明度的白色背景
            });
            jq.getJSON('',function(data){
                if(data.code == 200){
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                        location.reload();//do something
                    });
                }else{
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                }
            });
        });
    });
</script>
</body>
</html>